package com.kj.platformlogistics.home.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.kj.platformlogistics.R;
import com.kj.platformlogistics.base.BaseActivity;

public class PrintQrCodeActivity extends BaseActivity implements View.OnClickListener {
    private String qrCode="";
    private String goodsName="";
    private String goodsNumber="";
    private String postAddress="";
    private String receiveaddress="";
    private String ordernumber="";

    private ImageView ivQrCode;
    private TextView tvGoodsName,tvGoodsNumber,tvAddress,tvOrderNumber,tvSurePrint;

    public static void actionStart(Context context,String qrCode,String goodsName,
                                   String goodsNumber,
                                   String postAddress,
                                   String receiveaddress,
                                   String ordernumber) {
        Intent intent = new Intent(context, PrintQrCodeActivity.class);
        intent.putExtra("qrCode",qrCode);
        intent.putExtra("goodsName",goodsName);
        intent.putExtra("goodsNumber",goodsNumber);
        intent.putExtra("postAddress",postAddress);
        intent.putExtra("receiveaddress",receiveaddress);
        intent.putExtra("ordernumber",ordernumber);
        context.startActivity(intent);
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        setAndroidNativeLightStatusBar(true);
    }

    @Override
    protected int setLayoutResourceID() {
        return R.layout.activity_printqrcode;
    }

    @Override
    protected void initView() {
        setTitleText("打印二维码");
        qrCode=getIntent().getStringExtra("qrCode");
        goodsName=getIntent().getStringExtra("goodsName");
        goodsNumber=getIntent().getStringExtra("goodsNumber");
        postAddress=getIntent().getStringExtra("postAddress");
        receiveaddress=getIntent().getStringExtra("receiveaddress");
        ordernumber=getIntent().getStringExtra("ordernumber");
        ivQrCode=findViewById(R.id.ivQrCode);
        tvGoodsName=findViewById(R.id.tvGoodsName);
        tvSurePrint=findViewById(R.id.tvSurePrint);
        tvOrderNumber=findViewById(R.id.tvOrderNumber);
        tvGoodsNumber=findViewById(R.id.tvGoodsNumber);
        tvAddress=findViewById(R.id.tvAddress);


        tvSurePrint.setOnClickListener(this);
        tvGoodsName.setText("商品名称："+goodsName);
        tvGoodsNumber.setText("商品数量："+goodsNumber+"件");
        tvAddress.setText("收发地："+postAddress+"-->"+receiveaddress);
        tvOrderNumber.setText(ordernumber);
        Glide.with(PrintQrCodeActivity.this).load(qrCode)
                .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
                .into(ivQrCode);
    }

    @Override
    protected void initData() {
    }

    @Override
    protected int getTitleBarType() {
        return 0;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tvSurePrint:
                //确认打印

                break;
        }
    }
}
